#include "IrrCompileConfig.h"
#include "gameEngine.h"
#include "CGameSceneFactory.h"
#ifdef _IRR_PSP_
#include "common.h"
#define printf pspDebugScreenPrintf
#else
#pragma comment(lib, "Irrlicht.lib")
#endif

using namespace game;
using namespace scene;

int main()
{
#ifdef _IRR_PSP_
	setupPSP();
	pspDebugScreenInit();
#endif
	
	game::IDeviceManager* devManager = game::getDeviceManager();

	while(!devManager->getIsVideoDeviceRun())
	{
		game::irrThread::sleep(100);
	}

#ifdef _IRR_PSP_
	irr::core::stringc fileScene = "ms0:/data/config/ingamescene.xml";
#else
	irr::core::stringc fileScene = "./data/config/ingamescene.xml";
#endif

	registerSceneTypes(devManager->getGameSceneManager());

	IGameScene* scene = devManager->getGameSceneManager()->getGameScene(fileScene.c_str());

	devManager->getGameSceneManager()->setCurrentGameScene(scene);

#ifdef _IRR_PSP_
	sceKernelSleepThreadCB();
#else
	devManager->getVideoThread()->join();
#endif
	return 0;
}


///*
//This tutorial show how to make you first LTE Game Engine homebrew,
//the first thing to do to use the engine is to include the file
//<engine.h>, all is stored there.
//
//*/
//#include <irrlicht.h>
//#ifdef _IRR_PSP_
//#include "../common.h"
//#endif
//
//using namespace irr;
//
//using namespace core;
//using namespace scene;
//using namespace video;
//using namespace io;
//using namespace gui;
//using namespace audio;
//
//void AddNode(irr::scene::ISceneManager* smgr, irr::core::stringc meshFile, irr::core::stringc textureFile)
//{
//	IAnimatedMesh* mesh = smgr->getMesh(meshFile.c_str());
//	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
//
//	if (node)
//	{
//		node->setMaterialFlag(EMF_LIGHTING, false);
//		node->setMaterialTexture( 0, smgr->getVideoDriver()->getTexture(textureFile.c_str()));
//
//		//node->setScale(core::vector3df(f, 10.7f, 10.7f));
//	}
//}
//
//int main()
//{
//#ifdef _IRR_PSP_
//	setupPSP();
//#endif
//
//#ifdef _IRR_PSP_
//	irr::core::stringc file1 = "ms0:/data/meshes/steam/walk_bodyup01.b3d";
//	irr::core::stringc texture1 = "ms0:/data/textures/steam/bodyup.png";
//
//	irr::core::stringc file2 = "ms0:/data/meshes/steam/walk_hat.b3d";
//	irr::core::stringc texture2 = "ms0:/data/textures/steam/hat.png";
//
//
//	irr::core::stringc file3 = "ms0:/data/meshes/steam/walk_head.b3d";
//	irr::core::stringc texture3 = "ms0:/data/textures/steam/body.png";
//
//
//	irr::core::stringc file4 = "ms0:/data/meshes/steam/walk_leg.b3d";
//	irr::core::stringc texture4 = "ms0:/data/textures/steam/body.png";
//
//
//	irr::core::stringc file5 = "ms0:/data/meshes/steam/walk_shoulder.b3d";
//	irr::core::stringc texture5 = "ms0:/data/textures/steam/shoulder.png";
//
//	irr::core::stringc file6 = "ms0:/data/meshes/steam/walk_weapon.b3d";
//	irr::core::stringc texture6 = "ms0:/data/textures/steam/weapon.png";
//#else
//	irr::core::stringc file1 = "./data/meshes/steam/walk_bodyup01.b3d";
//	irr::core::stringc texture1 = "./data/textures/steam/bodyup.png";
//
//	irr::core::stringc file2 = "./data/meshes/steam/walk_hat.b3d";
//	irr::core::stringc texture2 = "./data/textures/steam/hat.png";
//
//
//	irr::core::stringc file3 = "./data/meshes/steam/walk_head.b3d";
//	irr::core::stringc texture3 = "./data/textures/steam/body.png";
//
//
//	irr::core::stringc file4 = "./data/meshes/steam/walk_leg.b3d";
//	irr::core::stringc texture4 = "./data/textures/steam/body.png";
//
//
//	irr::core::stringc file5 = "./data/meshes/steam/walk_shoulder.b3d";
//	irr::core::stringc texture5 = "./data/textures/steam/shoulder.png";
//
//	irr::core::stringc file6 = "./data/meshes/steam/walk_weapon.b3d";
//	irr::core::stringc texture6 = "./data/textures/steam/weapon.png";
//#endif
//
//	IrrlichtDevice* device = createDevice();
//
//	IVideoDriver* driver = device->getVideoDriver();
//	ISceneManager* smgr = device->getSceneManager();
//	IGUIEnvironment* guienv = device->getGUIEnvironment();
//
//	gui::IGUIStaticText* statusText = guienv->addStaticText(L"Hello World!",
//		rect<int>(10,10,260,22), true);
//
//
//	AddNode(smgr, file1, texture1);
//	AddNode(smgr, file2, texture2);
//	AddNode(smgr, file3, texture3);
//	AddNode(smgr, file4, texture4);
//	AddNode(smgr, file5, texture5);
//	AddNode(smgr, file6, texture6);
//
//
//	irr::scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
//	camera->setPosition(irr::core::vector3df(0,50,50));
//	camera->setTarget(irr::core::vector3df(0,0,0));
//	while(device->run())
//	{
//
//		driver->beginScene(true, true, SColor(255,100,101,140));
//
//		smgr->drawAll();
//		guienv->drawAll();
//
//		driver->endScene();
//
//
//		core::stringw status = L"Hello World! FPS = ";
//		status += driver->getFPS();		
//		statusText->setText(status.c_str());
//	}
//
//#ifdef _IRR_PSP_
//	sceKernelSleepThreadCB();
//#endif
//	return 0;
//}
//



